package com.crm.controller;

import com.crm.domain.entity.CustomerService;
import com.crm.result.Result;
import com.crm.service.CustomerServiceService;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

/**
 * 客户服务控制器
 */
@RestController
@RequestMapping("/customer-service")
public class CustomerServiceController {

    @Resource
    private CustomerServiceService service;


    // 服务创建
    @RequestMapping("/create")
    public Result<Boolean> create(CustomerService s) {
        return service.add(s) ? Result.success() : Result.failure();
    }


    // 服务分配
    @RequestMapping("/assign")
    public Result<Boolean> assign(CustomerService s) {
        return service.upd(s) ? Result.success() : Result.failure();
    }


    // 服务处理
    @RequestMapping("/process")
    public Result<Boolean> process(CustomerService s) {
        return service.upd(s) ? Result.success() : Result.failure();
    }


    // 服务反馈
    @RequestMapping("/feedback")
    public Result<Boolean> feedbackCustomerService(CustomerService s) {
        return service.upd(s) ? Result.success() : Result.failure();
    }


    // 服务归档
    @RequestMapping("/archive")
    public Result<List<CustomerService>> archive(CustomerService s) {
        return Result.success(service.findAll(s));
    }

}
